package com.bwie.utils;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/7/24 16:31
 */

public class TokenUtil {
    public static Integer getUserId(String token) {
        Claims body = Jwts.parser().setSigningKey("123456").parseClaimsJws(token).getBody();
        Integer userId = body.get("userId", Integer.class);
        return userId;
    }

    public static String getUserName(String token) {
        Claims body = Jwts.parser().setSigningKey("123456").parseClaimsJws(token).getBody();
        String userName = body.get("userName", String.class);
        return userName;
    }
}
